package com.hl.qzzpbackend.controller;
import com.hl.qzzpbackend.common.BaseResponse;
import com.hl.qzzpbackend.common.DeleteRequest;
import com.hl.qzzpbackend.common.ResultUtils;
import com.hl.qzzpbackend.model.dto.jobExpectation.JobExpectationAddRequest;
import com.hl.qzzpbackend.model.dto.jobExpectation.JobExpectationUpdateRequest;
import com.hl.qzzpbackend.model.vo.JobExpectationVO;
import com.hl.qzzpbackend.service.JobExpectationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;


/**
 * 求职期望接口
 *
 * @author helong
 */
@Slf4j
@Api(tags = "求职期望接口")
@RestController
@RequestMapping("/job_expectation")
public class JobExpectationController {

    @Resource
    private JobExpectationService jobExpectationService;


    // 新增求职期望
    @ApiOperation(value = "新增求职期望")
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public BaseResponse<Boolean> jobExpectationAdd(@Valid @RequestBody JobExpectationAddRequest jobExpectationAddRequest) {
        if(log.isInfoEnabled()){
            log.info("新增求职期望 {}", jobExpectationAddRequest);
        }
        boolean result = jobExpectationService.jobExpectationAdd(jobExpectationAddRequest);
        return ResultUtils.success(result);
    }

    // 更新求职期望
    @ApiOperation(value = "更新求职期望")
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public BaseResponse<Boolean> jobExpectationUpdate(@Valid @RequestBody JobExpectationUpdateRequest jobExpectationUpdateRequest) {
        if(log.isInfoEnabled()){
            log.info("更新求职期望 {}", jobExpectationUpdateRequest);
        }
        boolean result = jobExpectationService.jobExpectationUpdate(jobExpectationUpdateRequest);
        return ResultUtils.success(result);
    }

    // 删除求职期望
    @ApiOperation(value = "删除求职期望")
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public BaseResponse<Boolean> jobExpectationDelete(@Valid @RequestBody DeleteRequest deleteRequest) {
        if(log.isInfoEnabled()){
            log.info("删除求职期望 {}", deleteRequest);
        }
        boolean result = jobExpectationService.jobExpectationDelete(deleteRequest);
        return ResultUtils.success(result);
    }

    // 获取求职期望列表
    @ApiOperation(value = "获取求职期望列表")
    @RequestMapping(value = "/list/{id}", method = RequestMethod.POST)
    public BaseResponse<List<JobExpectationVO>> getJobExpectationList(@PathVariable("id") Long userId) {
        if(log.isInfoEnabled()){
            log.info("获取求职期望列表 userId:{}", userId);
        }
        List<JobExpectationVO> jobExpectationList = jobExpectationService.getJobExpectationList(userId);
        return ResultUtils.success(jobExpectationList);
    }

}
